from django.urls import path, re_path, include

from . import views

app_name = 'users'
urlpatterns = [
    # 用户注册
    # 用户注册: reverse(users:register) == '/register/'
    re_path('^register/', views.RegisterView.as_view(), name='register'),
    # 验证用户名是否存在
    re_path(r'^usernames/(?P<username>[a-zA-Z0-9_-]{5,20})/count/$', views.UsernameCountView.as_view()),
    # 验证手机号码是否存在
    re_path(r'^check_mobile/(?P<mobile>1[3-9]\d{9})/count/$', views.MobileCountView.as_view()),

    re_path(r'^login/$', views.LoginView.as_view(), name='login'),
    re_path(r'^logout/$', views.LogoutView.as_view(), name='logout'),
    re_path(r'^info/$', views.UserCenterInfoView.as_view(), name='info'),
    re_path(r'^emails/$', views.EmailView.as_view()),
    re_path(r'^emails/verification/$', views.VerifyEmailView.as_view()),
    # 创建地址
    re_path(r'^addresses/create/$', views.CreateAddressView.as_view()),
    # 查询地址
    re_path(r'^addresses/$', views.AddressView.as_view(), name='addresses'),
    # 更新和删除地址
    re_path(r'^addresses/(?P<address_id>\d+)/$', views.UpdateDestroyAddressView.as_view()),
    # 设置默认地址
    re_path(r'addresses/(?P<address_id>\d+)/default/$', views.DefaultAddressView.as_view()),
    # 修改标题
    re_path(r'addresses/(?P<address_id>\d+)/title/', views.UpdateTitleAddressView.as_view()),
    # 修改标题
    re_path(r'^changepassword/', views.ChangePasswordView.as_view(), name='changepassword'),
    # 用户浏览记录
    re_path(r'^browse_histories/', views.UserBrowseHistory.as_view()),

]
